<?php $section_name_list=array()?>
<div class="SipeiStat border_3 pb20 centered back_bgf mt20">   
    <h1 class="clearfix pl20 mb20 fonts_18 height40 fontc_444 fontw_normal back_bgfd"><?php echo $this->title; ?></h1>
     
            <div id="container1" style="width:90%;margin:0 auto;"></div>  
    <div style="clear:both"></div>
        <table class="fontc_666 height32">
            <thead class="back_bgf5 fontc_999">
                <tr>
                    <th width="90" align="center" class="border_d">区域</th>
                    <th width="87" align="center" class="border_d">理科</th>
                    <?php foreach($mainSubjectNameList AS $k=>$v):?>
                        <th width="87" align="center" class="border_d"></th>
                    <?php endforeach;?>
                    <th width="87" align="center" class="border_d">文科</th>
                    <?php foreach($mainSubjectNameList AS $k=>$v):?>
                        <th width="87" align="center" class="border_d"></th>
                    <?php endforeach;?> 
                </tr>
            </thead>
            <tbody class="fontc_444">
                <tr>
                    <td align="center" class="border_d"></td>
                    <td align="center" class="border_d">人数</td>
                    <?php foreach($mainSubjectNameList AS $k=>$v):?>
                        <td align="center" class="border_d"><?php echo $v;?></td>
                    <?php endforeach;?>
                    <td align="center" class="border_d">人数</td>    
                    <?php foreach($mainSubjectNameList AS $k=>$v):?>
                        <td align="center" class="border_d"><?php echo $v;?></td>
                    <?php endforeach;?> 
                </tr>  
                <tr>
                    <td align="center" class="border_d"><?php echo $cityName?></td>
                    <?php $pepole_num = isset($cityScoreTotal[1]['pople_num'])?$cityScoreTotal[1]['pople_num']:'0';?>
                    <td align="center" class="border_d"><?php echo $pepole_num;?></td> 
                    <?php foreach($mainSubjectNameList AS $k=>$v):?>
                    <?php $subject_score = isset($cityScoreTotal[1][$k]['score'])?$cityScoreTotal[1][$k]['score']:'0';?>
                    <?php $pepole_num = isset($cityScoreTotal[1][$k]['pople_num'])?$cityScoreTotal[1][$k]['pople_num']:'0';?>
                    <td align="center" class="border_d"><?php echo round($pepole_num?$subject_score/$pepole_num:0,2);?></td>
                    <?php endforeach;?>
                     <td align="center" class="border_d"><?php echo isset($cityScoreTotal[2]['pople_num'])?$cityScoreTotal[2]['pople_num']:'0';?></td> 
                    <?php foreach($mainSubjectNameList AS $k=>$v):?>
                      <?php $pepole_num = isset($cityScoreTotal[2][$k]['pople_num'])?$cityScoreTotal[2][$k]['pople_num']:'0';?>
                      <?php $subject_score = isset($cityScoreTotal[2][$k]['score'])?$cityScoreTotal[2][$k]['score']:'0';?>
                     <td align="center" class="border_d"><?php echo round($pepole_num?$subject_score/$pepole_num:0,2);?></td>
                    <?php endforeach;?>
                </tr> 
                <?php $section_data1 = $section_data2 = array()?>
               <?php foreach($scoreList AS $region_id=>$regionScore):?>
                    <tr>
                        <td align="center" class="border_d"><?php echo isset($areaList[$region_id])?$areaList[$region_id]:''?></td>
                        <?php $pepole_num = isset($regionScore[1]['pople_num'])?$regionScore[1]['pople_num']:'0';?>
                        <td align="center" class="border_d"><?php echo $pepole_num;?></td> 
                        <?php $xx = $t_arr = array();?>
                        <?php foreach($mainSubjectNameList AS $k=>$v):?> 
                        <td align="center" class="border_d"><?php echo isset($regionScore[1][$k]['avg_score'])?$regionScore[1][$k]['avg_score']:0;?></td>
                        <?php  
                        $xx[] = isset($regionScore[1][$k]['avg_score'])?$regionScore[1][$k]['avg_score']:0; 
                          
                        ?>
                        <?php endforeach;?> 
                        <?php
                        $t_arr['name'] = isset($areaList[$region_id])?$areaList[$region_id]:' 11';
                        $t_arr['data'] = $xx;
                        $t_arr['stack'] = '理科';
                        $section_data1[] = $t_arr;
                        ?>
                        <?php $pepole_num = isset($regionScore[2]['pople_num'])?$regionScore[2]['pople_num']:'0';?>
                        <td align="center" class="border_d"><?php echo $pepole_num;?></td> 
                        <?php  $xx = $t_arr = array();?>
                        <?php foreach($mainSubjectNameList AS $k=>$v):?> 
                        <td align="center" class="border_d"><?php  echo isset($regionScore[2][$k]['avg_score'])?$regionScore[2][$k]['avg_score']:0;?></td>
                        <?php  
                        $xx[] = isset($regionScore[2][$k]['avg_score'])?$regionScore[2][$k]['avg_score']:0; 
                        ?>
                        <?php endforeach;?>
                        <?php
                        $t_arr['name'] = isset($areaList[$region_id])?$areaList[$region_id]:' ';
                        $t_arr['data'] = $xx;
                        $t_arr['stack'] = '文科';
                        $section_data1[] = $t_arr; ?>
                    </tr>
                <?php endforeach;?>
            </tbody>
        </table> 
</div> 
<script type="text/javascript">
    function charts_line(id,title,type, categories, data) {
        $(id).highcharts({
            title: {
                text: title,
                x: 0 //
            },
            subtitle: {
                text: type,
                x: 0
            },
            xAxis: {
                categories: categories
            },
            yAxis: {
                title: {
                    text: ''
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
            formatter: function() {
                    return '<b>'+ this.x +'</b><br/>'+
                        this.series.name +': '+ this.y +'分<br/>';
                }
            },
            plotOptions: {
                column: {
                    stacking: 'normal'
                }
            },
            credits: {
                text: '',
                href: 'http://www.example.com'
            },
            chart: {
                type: 'column'
            },
            series: data
        });
    }
    <?php  
        foreach($mainSubjectNameList AS $k=>$v){
            $section_name_list[] = $v;
        }
        $section_name_list = json_encode($section_name_list);
        $section_data_list1 = json_encode($section_data1);
        $section_data_list2 = json_encode($section_data2);
    ?>
    $(function() {
        var type = '（平均分）',
            categories = <?php echo $section_name_list; ?>,
            data = <?php echo $section_data_list1; ?>;
            charts_line('#container1','文理科三门主课平均分对比图',type, categories, data);
    }); 
</script>